﻿<?xml version="1.0" encoding="utf-8" ?>
<Recipe Name="CreateProviderHierarchy" Bound="false" Recurrent="true" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns="http://schemas.microsoft.com/pag/gax-core" >
  <DocumentationLinks>
    <Link Kind="Documentation" Caption="How To: Create a Provider Factory and Base" Url="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ms.EntLib.2007Apr/EnterpriseLibrary/html/10-050-How_To_Create_a_Provider_Factory_and_Base.htm" />
    <Link Kind="NextStep" Caption="New Provider (Untyped)" Url="recipe://NewCustomProvider" />
    <Link Kind="NextStep" Caption="New Provider (Typed)" Url="recipe://NewProvider" />
    <Link Kind="NextStep" Caption="Create Design-Time Base Provider Node" Url="recipe://CreateDesignTimeAbstractNode" />
  </DocumentationLinks>
  <xi:include href="../Common/CommonTypeAliases.xml"
				xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Types)" />
	<Caption>New Provider Factory and Base</Caption>
	<Description>Creates a factory, interface and base class for a new provider type in a custom application block.</Description>
	<HostData>
		<CommandBar Menu="EnterpriseLibraryProjectMenu"/>
		<CommandBar Menu="EnterpriseLibraryFolder"/>
	</HostData>
	<Arguments>
		<Argument Name="AbstractionName" >
			<Converter Type="CodeIdentifierStringConverter"/>
		</Argument>
		<Argument Name="AbstractionCaption" >
			<ValueProvider Type="Evaluator" Expression="$(AbstractionName)" >
				<MonitorArgument Name="AbstractionName"/>
			</ValueProvider>
		</Argument>
		<Argument Name="CurrentProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
			<ValueProvider Type="Microsoft.Practices.RecipeFramework.Library.ValueProviders.FirstSelectedProject, Microsoft.Practices.RecipeFramework.Library" />
		</Argument>
		<Argument Name="CurrentFolder" Type="ProjectItem" Required="false" >
			<ValueProvider Type="CurrentItemProvider" />
		</Argument>
		<Argument Name="Namespace">
			<Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.NamespaceStringConverter, Microsoft.Practices.RecipeFramework.Library"/>
			<ValueProvider Type="Evaluator"
							 Expression="$(CurrentProject.Properties.Item('DefaultNamespace').Value)" />
		</Argument>
		<Argument Name="ExtendedNamespace" Required="false">
			<ValueProvider Type="Microsoft.Practices.EnterpriseLibrary.BlockFactory.ValueProviders.ExtendedNamespaceValueProvider, Microsoft.Practices.EnterpriseLibrary.BlockFactory"  
									   Folder="CurrentFolder" />
		</Argument>
		<Argument Name="ProjectName">
			<ValueProvider Type="Evaluator" Expression="$(CurrentProject.Name)" >
				<MonitorArgument Name="CurrentProject"/>
			</ValueProvider>
		</Argument>
		<Argument Name="DefaultInstanceName"  Required="false" >
			<ValueProvider Type="Evaluator" Expression="defaultName" />
		</Argument>
		<Argument Name="Polymorphic" Type="System.Boolean" >
			<ValueProvider Type="Evaluator" Expression="true" />
		</Argument>
		<Argument Name="Resources" Type="ProjectItem">
			<ValueProvider Type="ProjectItemByFullNameProvider" 
                     ProjectArgumentName="CurrentProject" 
                     ItemFullName="Resources.resx"
                     />
		</Argument>
		<xi:include href="..\Common\CommonTextTemplate.xml"
		xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(gax:Recipe/gax:Arguments/gax:Argument)" />
	</Arguments>
	<GatheringServiceData>
		<Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
			<Pages>
				<Page Type="Microsoft.Practices.EnterpriseLibrary.BlockFactory.CustomPages.NewProviderHierarchyPage, Microsoft.Practices.EnterpriseLibrary.BlockFactory" Width="800" Height="500">
					<Title>New Provider Factory and Base</Title>
					<LinkTitle>New Provider Factory and Base</LinkTitle>
					<Help></Help>
				</Page>
				<Page>
					<Title>New Provider Factory and Base</Title>
					<LinkTitle>New Provider Factory and Base Configuration</LinkTitle>
					<Help></Help>
					<Fields>
						<Field Label="Default Instance Name" ValueName="DefaultInstanceName">
							<Tooltip>Optional. Specifies the default name for the default instance.</Tooltip>
						</Field>
					</Fields>
				</Page>
			</Pages>
		</Wizard>
	</GatheringServiceData>
	<Actions>
    <Action   Name="CreateProviderHierarchyInfo" 
							Type="Microsoft.Practices.EnterpriseLibrary.BlockFactory.Actions.EnterpriseLibrary.CreateProviderHierarchyInfo, Microsoft.Practices.EnterpriseLibrary.BlockFactory">
			<Input Name="AbstractionName" RecipeArgument="AbstractionName" />
			<Input Name="AbstractionCaption" RecipeArgument="AbstractionCaption" />
			<Input Name="Namespace" RecipeArgument="Namespace" />
			<Input Name="Polymorphic" RecipeArgument="Polymorphic" />
			<Input Name="DefaultInstanceName" RecipeArgument="DefaultInstanceName" />
			<Input Name="ExtendedNamespace" RecipeArgument="ExtendedNamespace" />
			<Output Name="ProviderHierarchyInfo" />
      <Output Name="IsPolymorphic" />
    </Action>
		<Action Name="GenerateAbstractionInterfaceContent" Type="TextTemplateAction"
						Template="$TextTemplateBaseDirectory$ProviderHierarchy\IAbstraction.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionInterface" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" 
						TargetFileName="I$AbstractionName$.$LanguageFileExtension$"	>
			<Input Name="Item" RecipeArgument="CurrentFolder" />
			<Input	Name="Content" ActionOutput="GenerateAbstractionInterfaceContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionContent" Type="TextTemplateAction"
						Template="$TextTemplateBaseDirectory$ProviderHierarchy\Abstraction.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstraction" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" 
						TargetFileName="$AbstractionName$.$LanguageFileExtension$"	>
			<Input Name="Item" RecipeArgument="CurrentFolder" />
			<Input	Name="Content" ActionOutput="GenerateAbstractionContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionCustomFactoryContent" Type="TextTemplateAction"
						Template="$TextTemplateBaseDirectory$ProviderHierarchy\AbstractionCustomFactory.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionCustomFactory" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" 
						TargetFileName="$AbstractionName$CustomFactory.$LanguageFileExtension$"	>
			<Input Name="Item" RecipeArgument="CurrentFolder" />
			<Input	Name="Content" ActionOutput="GenerateAbstractionCustomFactoryContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionFactoryContent" Type="TextTemplateAction"
						Template="$TextTemplateBaseDirectory$ProviderHierarchy\AbstractionFactory.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionFactory" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" 
						TargetFileName="$AbstractionName$Factory.$LanguageFileExtension$"	>
			<Input Name="Item" RecipeArgument="CurrentFolder" />
			<Input	Name="Content" ActionOutput="GenerateAbstractionFactoryContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionInstanceFactoryContent" Type="TextTemplateAction"
						Template="$TextTemplateBaseDirectory$ProviderHierarchy\AbstractionInstanceFactory.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionInstanceFactory" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" 
						TargetFileName="$AbstractionName$InstanceFactory.$LanguageFileExtension$"	>
			<Input Name="Item" RecipeArgument="CurrentFolder" />
			<Input	Name="Content" ActionOutput="GenerateAbstractionInstanceFactoryContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionDataContent" Type="TextTemplateAction"
				Template="$TextTemplateBaseDirectory$ProviderHierarchy\Configuration\AbstractionData.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionData" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" ItemName="Configuration"
						TargetFileName="$AbstractionName$Data.$LanguageFileExtension$"	>
			<Input	Name="Content" ActionOutput="GenerateAbstractionDataContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionDataRetrieverContent" Type="TextTemplateAction"
				Template="$TextTemplateBaseDirectory$ProviderHierarchy\Configuration\AbstractionDataRetriever.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionDataRetriever" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" ItemName="Configuration"
						TargetFileName="$AbstractionName$DataRetriever.$LanguageFileExtension$"	>
			<Input	Name="Content" ActionOutput="GenerateAbstractionDataRetrieverContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
		<Action Name="GenerateAbstractionSettingsContent" Type="TextTemplateAction"
				Template="$TextTemplateBaseDirectory$ProviderHierarchy\Configuration\AbstractionSettings.t4">
			<Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
			<Output Name="Content" />
		</Action>
		<Action Name="AddAbstractionSettings" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" ItemName="ApplicationBlockSettings.$LanguageFileExtension$"
						TargetFileName="ApplicationBlockSettings.$AbstractionName$.$LanguageFileExtension$"	>
			<Input	Name="Content" ActionOutput="GenerateAbstractionSettingsContent.Content" />
			<Input	Name="Project" RecipeArgument="CurrentProject" />
			<Output Name="ProjectItem"/>
		</Action>
    <Action Name="GenerateAbstractionCustomDataContent" Type="TextTemplateAction"
    Template="$TextTemplateBaseDirectory$ProviderHierarchy\Configuration\AbstractionCustomData.t4">
      <Input Name="ProcessTemplate" ActionOutput="CreateProviderHierarchyInfo.IsPolymorphic" />
      <Input	Name="ProviderHierarchyInfo" ActionOutput="CreateProviderHierarchyInfo.ProviderHierarchyInfo"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddAbstractionCustomData" Type="AddItemFromStringActionPromptingExistence" PromptForOverwriting="true" ItemName="Configuration"
						TargetFileName="Custom$AbstractionName$Data.$LanguageFileExtension$"	>
      <Input Name="AddItem" ActionOutput="CreateProviderHierarchyInfo.IsPolymorphic" />
      <Input	Name="Content" ActionOutput="GenerateAbstractionCustomDataContent.Content" />
      <Input	Name="Project" RecipeArgument="CurrentProject" />
      <Output Name="ProjectItem"/>
    </Action>
    <Action Name="AddStringNullOrEmptyResource" Type="AddResource"  ResourceName="$AbstractionName$StringNullOrEmpty" ResourceValue="The value can not be an empty string or null." RunCustomTool="false">
			<Input Name="Resources" RecipeArgument="Resources" />
		</Action>
		<Action Name="AddSimpleProviderNotFoundResource" Type="AddResource" ResourceName="$AbstractionName$SimpleProviderNotFound" ResourceValue="The requested $AbstractionName$ provider '{0}' could not be found." >
			<Input Name="Resources" RecipeArgument="Resources" />
		</Action>
	</Actions>
</Recipe>